import {
	priceFormat
} from '@/utils/tools.js'

const getters = {
	statusBarHeight: state => state.system.statusBarHeight,
	titleBarHeight: state => state.system.titleBarHeight,
	bodyBarHeight: state => {
		if (state.system.foldState)
			return state.system.titleBarHeight;
		return 100;
	},
	totalHeight: state => {
		if (state.system.foldState)
			return state.system.statusBarHeight + state.system.titleBarHeight + 10;
		return state.system.statusBarHeight + state.system.titleBarHeight + 100 + 10;
	},

	foldState: state => state.system.foldState,
	carsList: state => state.cars.carsList,
	// 合计
	totalPrice: state => {
		return state.cars.carsList.reduce((previous, current) => {
			return previous += current.price * current.numvalue;
		}, 0)
	},
	preferentialPrice: state => {
		let price = state.cars.carsList.reduce((previous, current) => {
			return previous += current.price * current.numvalue;
		}, 0)

		let before = state.cars.carsList.reduce((previous, current) => {
			return previous += current.before_price * current.numvalue;
		}, 0)

		return before - price
	},
	buyNum: state => {
		return state.cars.carsList.reduce((previous, current) => {
			return previous += current.numvalue;
		}, 0)
	},
	brandData: state => {
		return state.brand.brandData
	},
	detailPopState: state => state.goods.detailPopState,
	detailData: state => {
		return state.goods.detailData
	},
	proSpecsState: state => {
		return state.goods.proSpecsState
	},
}

export default getters;